package com.xm.xmapp.dialog;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.xm.xmapp.R;
import com.xm.xmapp.adapter.BankMoneyAdapter;
import com.xm.xmapp.response.bean.ResponseMoneyListRefund;

public class SumbitBankMoneyDialog extends Dialog {
	private Activity context;
	private ArrayList<ResponseMoneyListRefund> list;
	private int payment_type;

	public SumbitBankMoneyDialog(int payment_type, Activity context, List<ResponseMoneyListRefund> list) {
		super(context, R.style.Dialog);
		this.context = context;
		this.list = (ArrayList<ResponseMoneyListRefund>) list;
		this.payment_type = payment_type;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		init();
	}

	public void init() {
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.dialog_sumbitbank_money, null);
		setContentView(view);

		view.findViewById(R.id.cancle).setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
		ListView mListView = (ListView) view.findViewById(R.id.mListView);
		BankMoneyAdapter adapter = new BankMoneyAdapter(list, context, R.layout.item_sumbitbank_money);
		adapter.setPayment_type(payment_type);
		mListView.setAdapter(adapter);

		ImageView iv_img = (ImageView) view.findViewById(R.id.iv_img);
//		TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
//		// 1=微信公众号，2=支付宝，6=微信app
		switch (payment_type) {
		case 1:
			iv_img.setImageResource(R.mipmap.wechat_icon);
//			tv_title.setText("微信公众号(元)");
			break;
		case 2:
			iv_img.setImageResource(R.mipmap.zhifu_icon);
//			tv_title.setText("支付宝(元)");
			break;
		case 6:
			iv_img.setImageResource(R.mipmap.wechat_icon);
//			tv_title.setText("微信(元)");
			break;

		default:
			break;
		}

		Window dialogWindow = getWindow();
		WindowManager.LayoutParams lp = dialogWindow.getAttributes();
		DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
		lp.width = (int) (d.widthPixels * 0.9); // 高度设置为屏幕的0.6
		lp.height = (int) (lp.width * 0.8);
		dialogWindow.setAttributes(lp);
	}
}
